﻿using AutoMapper;
using Modules;
using Modules.Template;
using PmSoft;

namespace ManagementApi.Models.Template
{
    public class SysTemplateDto
    {
        /// <summary>
        /// 主键
        ///</summary>
        public string Id { get; set; }

        /// <summary>
        /// 模板类型
        ///</summary>
        public 模板类型 Type { get; set; }

        /// <summary>
        /// 模板名称
        ///</summary>
        public string Name { get; set; }

        /// <summary>
        /// 桶名称
        ///</summary>
        public string BucketName { get; set; }

        /// <summary>
        /// 对象名称
        ///</summary>
        public string ObjectFilePath { get; set; }

        /// <summary>
        /// 友好的名称
        ///</summary>
        public string FriendlyName { get; set; }

        /// <summary>
        /// 媒体类型
        ///</summary>
        public byte? MediaType { get; set; }

        /// <summary>
        /// 附件MIME类型
        ///</summary>
        public string? ContentType { get; set; }

        /// <summary>
        /// 附件描述
        ///</summary>
        public string? Discription { get; set; }
    }

    public static partial class SysTemplateExceptions
    {
        public static SysTemplateDto AsDto(this SysTemplate entity)
        {
            var mapper = ServiceAccessor.GetService<IMapper>();
            return mapper.Map<SysTemplateDto>(entity);
        }

        public static IEnumerable<SysTemplateDto> AsDtos(this IEnumerable<SysTemplate> sysTemplates)
        {
            var mapper = ServiceAccessor.GetService<IMapper>();
            return mapper.Map<IEnumerable<SysTemplateDto>>(sysTemplates);
        }
    }
}